<template>
  <div class="app-user-login">
    <h2>APP用户登录</h2>
    <el-form :model="form" label-width="100px" @submit.prevent="onSubmit">
      <el-form-item label="账号">
        <el-input v-model="form.account" placeholder="请输入账号" />
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.password" type="password" placeholder="请输入密码" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">登录</el-button>
      </el-form-item>
    </el-form>
    <div v-if="user" class="result">
      <p>登录成功：{{ user.nickname || user.account }}</p>
    </div>
  </div>
</template>

<script>
import { AppUserApi } from './api/AppUserApi'

export default {
  name: 'AppUserLogin',
  data() {
    return {
      form: { account: '', password: '' },
      user: null,
    }
  },
  methods: {
    async onSubmit() {
      const res = await AppUserApi.login(this.form)
      if (res && res.success) {
        this.user = res.data
        this.$message.success('登录成功')
      } else {
        this.$message.error(res?.message || '登录失败')
      }
    },
  },
}
</script>

<style scoped>
.app-user-login { max-width: 420px; margin: 24px auto; }
</style>